]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
padOsd: Simplify continuation of edition into further ring/strip directions
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 16 May 2023 16:11:45 +0000 (18:11 +0200)
committerMarge Bot <marge-bot@gnome.org>
Mon, 7 Aug 2023 20:49:20 +0000 (20:49 +0000)
Inline the checks, so that we call stopEdition() from a single place.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2766>

js/ui/padOsd.js

index 43e28dcba6923c9fbcf7fe8131519844a45d56a0..fd25c469ea85920c1cc14b481276ab50845daa9a 100644 (file)
@@ -313,7 +313,6 @@ const PadDiagram = GObject.registerClass({
         let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/pad-osd.css');
         let [success_, css] = file.load_contents(null);
         this._curEdited = null;
-        this._prevEdited = null;
         this._css = new TextDecoder().decode(css);
         this._labels = [];
         this._activeButtons = [];
@@ -589,20 +588,12 @@ const PadDiagram = GObject.registerClass({
         label.show();
     }
 
-    stopEdition(continues, str) {
+    stopEdition(str) {
         this._editorActor.hide();
 
-        if (this._prevEdited) {
-            const { label, action, idx, dir } = this._prevEdited;
-            this._applyLabel(label, action, idx, dir, str);
-            this._prevEdited = null;
-        }
-
         if (this._curEdited) {
             const { label, action, idx, dir } = this._curEdited;
             this._applyLabel(label, action, idx, dir, str);
-            if (continues)
-                this._prevEdited = this._curEdited;
             this._curEdited = null;
         }
 
@@ -874,35 +865,27 @@ export const PadOsd = GObject.registerClass({
                 this._editedAction.dir == dir;
     }
 
-    _followUpActionEdition(str) {
-        let { type, dir, number, mode } = this._editedAction;
-        const hasNextAction =
-            type === Meta.PadFeatureType.RING && dir === Meta.PadDirection.CCW
-            || type === Meta.PadFeatureType.STRIP && dir === Meta.PadDirection.UP;
-        if (!hasNextAction)
-            return false;
-
-        this._padDiagram.stopEdition(true, str);
-        this._editedAction = null;
-        if (type === Meta.PadFeatureType.RING)
-            this._startRingActionEdition(number, Meta.PadDirection.CW, mode);
-        else
-            this._startStripActionEdition(number, Meta.PadDirection.DOWN, mode);
-
-        return true;
-    }
-
     _endActionEdition() {
         this._actionEditor.close();
 
         if (this._editedAction != null) {
-            const { type, number, dir, mode } = this._editedAction;
+            const {type, number, dir, mode} = this._editedAction;
             const str = this._getActionText(type, number, dir);
-            if (this._followUpActionEdition(str))
-                return;
 
-            this._padDiagram.stopEdition(false, str);
+            const hasNextAction =
+                type === Meta.PadFeatureType.RING && dir === Meta.PadDirection.CCW ||
+                type === Meta.PadFeatureType.STRIP && dir === Meta.PadDirection.UP;
+
+            this._padDiagram.stopEdition(str);
             this._editedAction = null;
+
+            // Maybe follow up on next ring/strip direction
+            if (hasNextAction) {
+                if (type === Meta.PadFeatureType.RING)
+                    this._startRingActionEdition(number, Meta.PadDirection.CW, mode);
+                else
+                    this._startStripActionEdition(number, Meta.PadDirection.DOWN, mode);
+            }
         }
 
         this._editedActionSettings = null;